package com.chuangjiangx.member.coupon.ddd.domain.model;

import com.chuangjiangx.dddbase.Entity;
import com.chuangjiangx.member.coupon.ddd.domain.model.GetChannelEnum;
import com.chuangjiangx.member.coupon.ddd.domain.model.MbrPayGiftCardRuleId;
import com.chuangjiangx.member.coupon.ddd.domain.model.MbrPayGiftCardWxStatusEnum;
import com.chuangjiangx.member.basic.ddd.domain.model.MerchantId;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 支付即会员规则
 * @author wp
 * @date 2018-08-31 15:23
 **/
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class MbrPayGiftCardRule extends Entity<MbrPayGiftCardRuleId>{

    private MerchantId merchantId;

    private String wxRuleId;

    private Date beginTime;

    private Date endTime;

    private BigDecimal leastCost;

    private BigDecimal maxCost;

    private List<GetChannelEnum> getChannelList;

    private MbrPayGiftCardWxStatusEnum wxStatus;

    private Date createTime;

    private Date updateTime;

    public void update(String wxRuleId, Date beginTime, Date endTime, BigDecimal leastCost, List<GetChannelEnum> getChannelList, MbrPayGiftCardWxStatusEnum wxStatus) {
        this.merchantId = merchantId;
        this.wxRuleId = wxRuleId;
        this.beginTime = beginTime;
        this.endTime = endTime;
        this.leastCost = leastCost;
        this.getChannelList = getChannelList;
        this.wxStatus = wxStatus;
        this.updateTime = new Date();
    }

    public MbrPayGiftCardRule(MerchantId merchantId, String wxRuleId, Date beginTime, Date endTime, BigDecimal leastCost,List<GetChannelEnum> getChannelList, MbrPayGiftCardWxStatusEnum wxStatus, Date createTime, Date updateTime) {
        this.merchantId = merchantId;
        this.wxRuleId = wxRuleId;
        this.beginTime = beginTime;
        this.endTime = endTime;
        this.leastCost = leastCost;
        this.maxCost = BigDecimal.ZERO;
        this.getChannelList = getChannelList;
        this.wxStatus = wxStatus;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public void updateWxStatus(String wxRuleId, MbrPayGiftCardWxStatusEnum wxStatus) {
        this.wxRuleId = wxRuleId;
        this.wxStatus = wxStatus;
    }
}
